package com.xhb.biz.service;

import com.baomidou.mybatisplus.solon.service.impl.ServiceImpl;
import com.xhb.biz.mapper.DownloadMapper;
import com.xhb.biz.po.DownloadPO;
import org.noear.solon.aspect.annotation.Service;

import java.util.Date;
import java.util.concurrent.CompletableFuture;

@Service
public class DownloadFileService extends ServiceImpl<DownloadMapper, DownloadPO> {

    /**
     * 异步插入
     *
     * @param downloadPO
     */
    public void insert(DownloadPO downloadPO) {
        downloadPO.setDownloadTime(new Date());
        super.save(downloadPO);
    }

    /**
     * 异步更新
     *
     * @param downloadPO
     */
    public void updateAsync(DownloadPO downloadPO) {
        CompletableFuture.runAsync(() -> {
            super.updateById(downloadPO);
        });
    }


    /**
     * 异步删除
     *
     * @param downloadPO
     */
    public void deleteAsync(DownloadPO downloadPO) {
        CompletableFuture.runAsync(() -> {
            super.removeById(downloadPO);
        });
    }


}
